package com.conte.services;

import com.awan.utils.Constanta;
import com.beem.project.beem.BeemApplication;
import com.beem.project.beem.ui.ContactList;
import com.beem.project.beem.ui.Login;
import com.beem.project.beem.ui.LoginAnim;
import com.beem.project.beem.ui.wizard.Account;
import com.beem.project.beem.utils.BeemBroadcastReceiver;


import android.app.Activity;
import android.app.AlarmManager;
import android.app.Application;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;

public class BootReciever extends BroadcastReceiver {
	
	private BeemApplication mApplication;
	private static final int LOGIN_REQUEST_CODE = 1;
	private static final int PERIOD=3000;//3600000;   // 5 minutes==300000
	 Activity act;
	 Application app;
	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		/*Intent myIntent = new Intent(context, Login.class);
		myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		context.startActivity(myIntent);*/

		/*if (context instanceof BeemApplication) {
		    mApplication = (BeemApplication) context;
		}*/
		
		Log.e(getClass().getName(),"BootReciever start");
			/*Bundle clipBundle = new Bundle();
			clipBundle.putBoolean("is_minimize", true);
			Intent i = new Intent(context, ContactList.class);
			i.putExtra("login_data", clipBundle);
			i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(i);*/
		
			//act=(Activity)context;
		
		
			Bundle clipBundle = new Bundle();
			clipBundle.putBoolean("is_minimize", true);
			Intent i = new Intent(context, LoginAnim.class);
			i.putExtra("login_data", clipBundle);
			i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(i);
			
			AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
		    Intent inte=new Intent(context, BeemBroadcastReceiver.class);
		    PendingIntent pi=PendingIntent.getBroadcast(context, 0,inte, 0);
		    mgr.set(AlarmManager.RTC_WAKEUP, SystemClock.elapsedRealtime()/*System.currentTimeMillis()*/ + PERIOD, pi);
		    
		
			/*if (context instanceof BeemApplication) {
			    mApplication = (BeemApplication) context;
			    act=(Activity)context;
			    app = act.getApplication();
			}
			
			if (app instanceof BeemApplication) {
				Log.e(getClass().getName(),"app instanceof BeemApplication");
				mApplication = (BeemApplication) app;
			    if (mApplication.isConnected()) {
			    	Constanta.setUserData(context);
			    	context.startActivity(new Intent(context, ContactList.class));
			    	//finish();
			    } else if (!mApplication.isAccountConfigured()) {
			    	context.startActivity(new Intent(context, Account.class));
			    	//finish();
			    }
			}*/
	
	}
}